package com.example.lin.ximalaya.adapter.viewholder;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.lin.ximalaya.R;
import com.example.lin.ximalaya.pojo.HotData;
import com.example.lin.ximalaya.pojo.Type20Or23ListItem;
import com.example.lin.ximalaya.utils.NumberUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class Type10or11ViewHolder extends RecyclerView.ViewHolder {

    private Context context;

    @BindView(R.id.iv_icon)
    ImageView ivIcon;
    @BindView(R.id.iv_ad)
    ImageView ivAd;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_descriptor)
    TextView tvDescriptor;

    public Type10or11ViewHolder(Context context, View itemView) {
        super(itemView);
        this.context = context;
        ButterKnife.bind(this, itemView);
    }

    /**
     * 为 ViewHolder 绑定数据
     *
     * @param data 数据对象
     */
    public void setData(HotData.ListBeanX data) {
        String name;
        String descriptor;
        String imageIconUrl;
        switch (data.getModuleId()) {
            case 11:
                imageIconUrl = "http://fdfs.xmcdn.com/group47/M0A/7C/69/wKgKk1tMNaKCMS_IAABRC7E6Qyk930.jpg";
                name = "喜马拉雅城市服务商招募令";
                descriptor = "和我们一起干大事";
                break;
            case 10:
                imageIconUrl = "http://fdfs.xmcdn.com/group46/M03/7B/A3/wKgKlluOTDmAHCAGAABgEDfWLxk307.jpg";
                name = "晓雅Mini AI音箱";
                descriptor = "开学季放价大促！";
                break;
            default:
                return;
        }
        Glide.with(context).load("http://fdfs.xmcdn.com/group30/M09/3A/2C/wKgJXlpgmDTy3BbRAAAGnuDtF7k609.png").into(ivAd);
        Glide.with(context).load(imageIconUrl).into(ivIcon);
        tvName.setText(name);
        tvDescriptor.setText(descriptor);
    }

}
